<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>Add RatePlan</title>
    <link type="text/css" href="${contextPath}/static/style/global.css" rel="stylesheet"/>
    <script type="text/javascript" src="${contextPath}/static/script/jquery/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="${contextPath}/static/script/jquery/jquery.validate.js"></script>
    <script type="text/javascript" language="JavaScript">
        function save() {
            $("input:checkbox").eq(0).val($("input:checkbox").eq(0).attr("checked"));
            $("#freeMeal_ratePlan").val($("#rate_plan_code").val());
            $("#mainForm").attr("action", "./update.dhtml");
            $("#mainForm").submit();
        }
        $(function() {
            $("#mainForm").validate();
        })
    </script>

</head>
<body>
<div class="main">
    <form id="mainForm">
    <fieldset>
        <legend>
            <span class="title">Rate Plan Information</span>
        </legend>
        <table class="table_list">
            <tr>
                <td class="key">Code:</td>
                <td class="value"><input type="text" value="${oldRatePlan.code}" id="rate_plan_code"
                                         minlength="1" maxlength="20" class="required"
                                         name="ratePlan.code" readonly="readonly"/></td>
            </tr>
            <tr>
                <td class="key">Name:</td>
                <td class="value"><input type="text" id="rate_plan_name" class="required" name="ratePlan.name"
                                         minlength="1" size="40" maxlength="50" value="${oldRatePlan.name}"/>
                </td>
            </tr>
            <tr>
                <td class="key">Description:</td>
                <td class="value"><textarea id="rate_plan_description" name="ratePlan.description"
                                            maxlength="250" cols="80">${oldRatePlan.description}</textarea>
                </td>
            </tr>
            <tr>
                <td class="key">FreeMealType:</td>
                <td class="value">
                    <select class="select" name="ratePlan.freeMeal.type">
                        <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.FreeMealType@values()"
                                    id="freeMealType">
                            <option
                                    <s:if test="oldRatePlan.freeMeal.type==#freeMealType">
                                        selected="selected"
                                    </s:if>
                                    value="${freeMealType}">${freeMealType}</option>
                        </s:iterator>
                    </select>
                </td>
            </tr>
            <tr>
                <input type="hidden" id="freeMeal_ratePlan" name="ratePlan.freeMeal.ratePlan"/>
                <td class="key">FreeMealUnit:</td>
                <td class="value">
                    <select class="select" name="ratePlan.freeMeal.unit">
                        <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.FreeMealUnit@values()"
                                    id="freeMealUnit">
                            <option
                                    <s:if test="oldRatePlan.freeMeal.unit==#freeMealUnit">
                                        selected="selected"
                                    </s:if>
                                    value="${freeMealUnit}">${freeMealUnit}</option>
                        </s:iterator>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="key">FreeMealQuantity:</td>
                <td class="value"><input type="text" class="longText" name="ratePlan.freeMeal.quantity"
                                         value="${oldRatePlan.freeMeal.quantity}"/></td>
            </tr>
            <tr>
                <td class="key">FreeMealDescription:</td>
                <td class="value"><input type="text" class="longText"
                                         name="ratePlan.freeMeal.description"
                                         value="${oldRatePlan.freeMeal.description}"/></td>
            </tr>
            <tr>
                <td class="key">Guarantee:</td>
                <td class="value">
                    <input type="checkbox" name="ratePlan.needGuarantee" <s:if test="oldRatePlan.needGuarantee">
                        checked="checked"
                    </s:if>/>NeedGuarantee
                </td>
            </tr>
            <tr>
                <td class="key">RateType:</td>
                <td class="value">
                    <select class="select" name="ratePlan.rateType">
                        <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.RateType@values()"
                                    id="rateType">
                            <option value="${rateType}">${rateType}</option>
                        </s:iterator>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="key">PaymentType:</td>
                <td class="value">
                    <select class="select" name="ratePlan.paymentType">
                        <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.PaymentType@values()"
                                    id="paymentType">
                            <option
                                    <s:if test="oldRatePlan.paymentType==#paymentType">
                                        selected="selected"
                                    </s:if>
                                    value="${paymentType}">${paymentType}</option>
                        </s:iterator>
                    </select>
                </td>
            </tr>
        </table>
    </fieldset>
    <input type="button" value="Save" class="common_button" onclick="save();"/>
    <input type="button" value="Back" class="common_button" onclick="window.location.href='./list.dhtml'"/>
</form>
</div>
</body>
</html>